//
//  APTagsViewCell.swift
//  APSwift
//
//  Created by jianbo.pei on 2022/9/13.
//

import UIKit
import Then
import SnapKit

class APTagsViewCell: UICollectionViewCell {
    func setup(with tagModel: APTagsModelProtocol?) {
        if tagModel == nil {
            return
        }
    }
}

class UIs_APTagsViewDemoSelectedCell: APTagsViewCell {
    private var tagNameLabel: UILabel!
    private var line: UIView!
    private var closeButton: UIButton!
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        initUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func initUI() {
        
        closeButton = UIButton(type: .custom).then({ make in
            contentView.addSubview(make)
            make.setImage(UIImage(named: "gb_component_close_black_20"), for: .normal)
            make.snp.makeConstraints { make in
                make.size.equalTo(12)
                make.right.equalTo(-8)
                make.centerY.equalToSuperview()
            }
        })
        
        line = UIView().then({ make in
            contentView.addSubview(make)
            make.backgroundColor = .purple
            make.snp.makeConstraints { make in
                make.size.equalTo(CGSize(width: 1, height: 9))
                make.right.equalTo(closeButton.snp.left).offset(-8)
                make.centerY.equalToSuperview()
            }
        })

        tagNameLabel = UILabel().then({ make in
            contentView.addSubview(make)
            make.snp.makeConstraints { make in
                make.left.equalTo(8)
                make.centerY.equalToSuperview()
                make.right.equalTo(line.snp.left).offset(-8).priority(.high)
            }
        })
        
    }
    
    override func setup(with tagModel: APTagsModelProtocol?) {
        super.setup(with: tagModel)
        if let tagM = tagModel as? UIs_TagsModel  {
            tagNameLabel.text = tagM.name
        }
    }
}

class UIs_APTagsViewDemoNormalCell: APTagsViewCell {
    private var tagNameLabel: UILabel!
    override func setup(with tagModel: APTagsModelProtocol?) {
        super.setup(with: tagModel)
    }
}
